//
//  HotMeActivityCell.m
//  jingdongfang
//
//  Created by MTiMac02 on 2018/5/9.
//  Copyright © 2018年 BOE-SBG-CTO. All rights reserved.
//

#import "HotMeActivityCell.h"
#import "MyFocusMemberModel.h"
@interface HotMeActivityCell()
{
     void(^blocks)(MyFocusMemberModel *info);
}
@property (strong, nonatomic) IBOutlet UIImageView *activityImage;
@property (strong, nonatomic) IBOutlet UILabel *activityName;
@property (strong, nonatomic) IBOutlet UILabel *activityNum;
@property (strong, nonatomic) IBOutlet UIButton *attentActivity;
@end
@implementation HotMeActivityCell

- (void)awakeFromNib {
    [super awakeFromNib];    
    self.attentActivity.clipsToBounds=YES;
    self.attentActivity.layer.borderWidth=1.0f;
    self.attentActivity.layer.cornerRadius=15.f;
    self.attentActivity.layer.borderColor=[UIColor c1Color].CGColor;
    self.attentActivity.contentEdgeInsets=UIEdgeInsetsMake(5, 10, 5, 10);
    self.attentActivity.titleLabel.font=[UIFont font14];
    [self.attentActivity setTitleColor:[UIColor c5Color] forState:UIControlStateSelected];
    [self.attentActivity setTitleColor:[UIColor c1Color] forState:UIControlStateNormal];
    [self.attentActivity setTitle:@"已关注" forState:UIControlStateSelected];
    [self.attentActivity setTitle:@"+ 关注" forState:UIControlStateNormal];
    [self.attentActivity addTarget:self action:@selector(attentBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.attentActivity setSelected:NO];
}
-(void)layoutSubviews{
    MyFocusMemberModel *info=self.data;
    [self.activityImage sd_setImageWithURL:[NSURL URLWithString:info.image]];
    self.activityName.text=info.title;
    self.activityNum.text=[NSString stringWithFormat:@"阅读%@",info.readNum];
    if ([info.attentionState integerValue]==0) { //是否 关注  0=已关注，1=未关注
        self.attentActivity.layer.borderColor = [UIColor c5Color].CGColor;
        self.attentActivity.selected=YES;
    } else {
        self.attentActivity.layer.borderColor = [UIColor c1Color].CGColor;
        self.attentActivity.selected=NO;
    }
}

-(void)attentBtnClick:(UIButton *)attBtn{
    self.attentActivity.selected=!self.attentActivity.isSelected;
    if ([self.attentActivity isSelected]) {
        self.attentActivity.layer.borderColor=[UIColor c5Color].CGColor;
    }else{
        self.attentActivity.layer.borderColor=[UIColor c1Color].CGColor;
    }
    if (blocks)
    {
        blocks((MyFocusMemberModel *)self.data);
    }
}
-(void)followOwerAction:(void (^)(MyFocusMemberModel *))block{
    blocks = [block copy];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
